import * as util from "node:util"

/** dinegg框架封装的错误抛出类，可以在错误捕获中间件中处理，适应前端响应 */
export default class DineggError extends Error {
    name = "DineggError"

    /** 可实现格式化消息内容 */
    constructor(msg: string, ...args: any[]) {
        msg = util.format(msg, ...args)
        super(msg)
    }

    /** 创建一个新实例 */
    public static New(msg: string, ...args: any[]) {
        return new DineggError(msg, ...args)
    }

}